import { useRef } from "react"

function useDebounce(fn, delay) {
    let timer = useRef(null)

    return (...arg) => {
        clearTimeout(timer.current)
        timer.current = setTimeout(() => {
            fn(...arg)
        }, delay)
    }
}

export default useDebounce
